import axios from '../utils/http'

const UserStore = {
    namespaced:true,
    state:()=>({
        user_list:[],
        count:0
    }),
    mutations:{
        UserMutation(state,list){
            state.user_list = list
        },
        UserCountMutation(state,count){
            state.count = count
        }
    },
    actions:{
        UserAction(context,page={page:1,size:10}){
            var url = '/api/userlist?page='+page.page+'&size='+page.size
            axios.get(url).then(res=>{
                if(res.code === 200){
                    context.commit('UserMutation',res.list)
                }
            })
        },
        UserCountAction(context){
            axios.get('/api/usercount').then(res=>{
                if(res.code === 200){
                    context.commit('UserCountMutation',res.list[0].total)
                }
            })
        }
    }
}

export default UserStore